<!-- 备案项目查询 -->
<template>
  <div class="home-index-content">
    <Table :columns="columns" :data="listData" :loading="isLoading">
      <template slot-scope="{ row }" slot="rate">
        <div class="repetition-rate" @click="repetitionRateFn(row)">
          <span>{{ row.repetitionRate }}%</span
          ><span class="line-primary">查看</span>
        </div>
      </template>
      <template slot-scope="{ row }" slot="serviceArea">
        {{ serviceAreaFn(row.serviceArea) }}
      </template>
      <template slot-scope="{ row }" slot="serviceType">
        {{ serviceTypeFn(row.serviceType) }}
      </template>
    </Table>
    <RepetitionRate
      v-if="isHide"
      :isHide="isHide"
      :updateIsHide.sync="isHide"
      :companyId="companyId"
    />
  </div>
</template>

<script type="text/javascript">
import { CompanyBusinessInfoChild } from "@/api/enterpriseInforManage.js";
import { returnStr } from "@/libs/util.js";
import RepetitionRate from "./repetitionRate";

export default {
  name: "expandTable",
  components: {
    RepetitionRate,
  },
  props: {
    row: {
      type: Object,
      default: () => {},
    },
    projectName: {
      type: String,
      defalt: "",
    },
  },
  data() {
    return {
      columns: [
        {
          title: "项目名称",
          key: "projectName",
        },
        {
          title: "重复率",
          slot: "rate",
        },
        {
          title: "业主方",
          key: "ownerCompanyName",
        },
        {
          title: "施工方",
          key: "constructionName",
        },
        {
          title: "预计产值规模",
          key: "outputScale",
        },
        {
          title: "发布时间",
          key: "createDateTime",
        },
        {
          title: "项目地址",
          key: "projectAddressName",
        },
        // {
        //   title: "地区",
        //   slot: "serviceArea",
        // },
        // {
        //   title: "产业标记",
        //   slot: "serviceType",
        // },
      ],
      listData: [],
      isLoading: false,
      isHide: false,
      companyId: "",
    };
  },
  methods: {
    async companyBusinessInfoChildData() {
      let companyId = this.$props.row.companyId;
      let params = {
        companyId,
        projectName:this.$props.projectName
      };
      this.isLoading = true;
      let data = await CompanyBusinessInfoChild(params);
      this.listData = data;
      this.isLoading = false;
    },
    serviceAreaFn(data) {
      return returnStr(data, "provinceName", "cityName");
    },
    serviceTypeFn(data) {
      return returnStr(data, "serviceTypeName");
    },
    // 查看重复率
    repetitionRateFn(row) {
      this.companyId = row.busiInfoId;
      this.isHide = true;
    },
  },
  mounted() {
    this.companyBusinessInfoChildData();
  },
};
</script>

<style lang="less" scoped>
.repetition-rate{
  cursor: pointer;
  .line-primary{
    color:#0052d9;
  }
}
</style>
